package com.apes.hr.salary.rewardPunish.repository;

import com.apes.framework.jpa.repository.CustomRepository;
import com.apes.hr.base.model.Employee;
import com.apes.hr.salary.rewardPunish.model.RewardPunishItem;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

/**
 * @author HuJianLin
 * @create 2018-05-09 16:07
 */
public interface RewardPunishItemRepository extends CustomRepository<RewardPunishItem, Long>{

    @Query(value =
            "select A.* from HR_REWARD_PUNISH T, HR_REWARD_PUNISH_ITEM A WHERE T.ID = A.REWARD_PUNISH_ID and t.reward_date>=?1 and t.state ='sendOut' and A.EMPLOYEE_ID =?2"
            ,nativeQuery = true)
    List<RewardPunishItem> findByRewardDate(Date oldYear, Employee employee);

    @Query(value = "SELECT A.*" +
            "  FROM HR_REWARD_PUNISH T, HR_REWARD_PUNISH_ITEM A" +
            " WHERE T.ID = A.REWARD_PUNISH_ID" +
            "   AND T.ID = ?1" +
            "   AND A.EMPLOYEE_ID =?2",nativeQuery = true)
    RewardPunishItem findByIDAndEmployee(String id, Employee employee);
}
